# -*- coding: utf-8 -*-
"""
Created on Tue Apr 23 20:17:39 2019

@author: yaoyu
"""

from PIL import Image
import numpy as np

a = np.array(Image.open('test0.jpg'))
print(a.shape, a.dtype)

b = [255, 255, 255] - a
im = Image.fromarray(b.astype('uint8'))
im.save('test2.jpg')

a = np.array(Image.open('test0.jpg').convert('L'))
if 0:
    b = 255 - a
    im = Image.fromarray(b.astype('uint8'))
    im.save('test3.jpg')
    
    c = (100/255)*a + 150
    im = Image.fromarray(c.astype('uint8'))
    im.save('test4.jpg')

d = 255 * (a/255)**2
im = Image.fromarray(d.astype('uint8'))
im.save('test5.jpg')
